$(document).ready(function () {
  queryList()
})

// 搜索
function searchBtn() {
  let formData = $('#formData').serializeArray()
  console.log('formData', formData);
}

// 重置
function resetBtn() {
  let form = document.getElementById('formData')
  form.reset()
  initForm()
}

// 更多展开
function unfoldMore() {
  let formDom = $('#search-form-box')[0]
  let moreIconDom = $('#s-more-icon')[0]
  if (formDom.classList.toString().indexOf('s-df') >= 0) {
    formDom.classList.remove('s-df')
    formDom.classList.add('s-unfold')
    moreIconDom.classList.add('up')
    $('#search-form-box').children('.d-none').addClass('d-flex');
    $('#search-form-box').children('.d-none').removeClass('d-none');
  } else {
    formDom.classList.add('s-df')
    formDom.classList.remove('s-unfold')
    moreIconDom.classList.remove('up')
    $('#search-form-box').children('.d-flex').addClass('d-none');
    $('#search-form-box').children('.d-flex').removeClass('d-flex');
  }
}

// 当前页数
var currentPage = 1;
// 总页数
var totals = 9;
// 总条数
var count = 42;

// 列表
var listData = []

// 上一页
function pageUp() {
  if (currentPage > 1) {
    currentPage--
    queryList()
  }
}

// 下一页
function pageDown() {
  if (currentPage < totals) {
    currentPage++
    queryList()
  }
}

// 获取列表
function queryList() {
  var listDom = $('#queryList');

  $('.operate-btn .show-info').text('共' + totals + '页/第' + currentPage + '页，共' + count + '条数据')
  listData = [{}, {}, {}, {}, {}]

  $(listDom).html('')

  for (var i = 0; i < listData.length; i++) {
    var item = listData[i];

    $(listDom).append(listItem(item))
  }
}

// 列表项
function listItem(data) {
  var html = '<li class="list-item">' +
    '<div class="item-title">' + '1、分档名称：单轴2000—2500mm旋耕机' + '</div>' +
    '<table border class="manage-table">' +
    '<tr>' +
    '<td class="label">机具大类</td>' +
    '<td class="value">' + '耕整地机械' + '</td>' +
    '<td class="label">机具小类</td>' +
    '<td class="value">' + '耕地机械' + '</td>' +
    '</tr>' +
    '<tr>' +
    '<td class="label">机具品目</td>' +
    '<td class="value">' + '旋耕机' + '</td>' +
    '<td class="label">生产企业</td>' +
    '<td class="value">' + '测试企业名称' + '</td>' +
    '</tr>' +
    '<tr>' +
    '<td class="label">产品名称</td>' +
    '<td class="value">' + '多功能变速旋耕机' + '</td>' +
    '<td class="label">型号</td>' +
    '<td class="value">' + '1GKNB-200G' + '</td>' +
    '</tr>' +
    '<tr>' +
    '<td class="label">基本配置与参数（投档档次）</td>' +
    '<td class="value" colspan="3">' + '轴数：单轴；耕幅：3333mm;' + '</td>' +
    '</tr>' +
    '</table>' +
    '</li>'
  return html
}